class ResultFormatMiddleware {
    constructor() {

    }

    _root(res, message, status, data) {
        return res.status(status).json({message, data})
    }

    success(res, message = 'ok', status = 200, data = []) {
        return this._root(res, message, status, data)
    }

    fail(res, message = 'fail', status = 500, data = []) {
        return this._root(res, message, status, data)
    }

}

module.exports = resultFormatMiddleware = new ResultFormatMiddleware()
